﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using FluentNHibernate;

namespace Mindfor.Web.Data.Mappings
{
	public class UserMap : ClassMap<User>
	{
		public UserMap()
		{
			Table("Users");
			Id(m => m.Id);
			Map(m => m.Login).Length(255).Not.Nullable();
			Map(Reveal.Member<User>("Password"));
			Map(m => m.PasswordRecoveryGuid);
			Map(m => m.Email).Length(255);
			Map(m => m.IsApproved);
			Map(m => m.IsBanned);
			Map(m => m.RegDate);
			Map(m => m.LastActivityDate);
			Map(m => m.LastPasswordChangeDate);
			Map(m => m.ActivationGuid);
			
			HasManyToMany<Role>(m => m.Roles).Table("UserRoles").ParentKeyColumn("UserId").ChildKeyColumn("RoleId");
		}
	}
}
